import type { StepExecutionModel } from '#/api/production/models';

import { requestClient } from '#/api/request';

/**
 * 查询产品生产工艺步骤数据
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getProcessStepPagedListApi(params: PageParams) {
  return requestClient.get<StepExecutionModel[]>(
    '/mes/traceability/workstation/list-page',
    {
      params,
    },
  );
}

/**
 * 下载指定数据文件的 Url
 * @param params 查询参数
 * @returns 返回要下载的路径
 */
export function downloadExcelApiUrl(params: any) {
  const params1 = Object.fromEntries(
    Object.entries(params).filter(([_, value]) => value !== undefined),
  ) as any;

  const qs = new URLSearchParams(params1);
  // TODO: 替换为实际的下载地址
  return `http://localhost:5001/api/mes/traceability/workstation/download?${qs.toString()}`;
}

/**
 * 根据筛选条件下载所有的数据文件的 Url
 * @param params 查询参数
 * @returns 返回要下载的路径
 */
export function downloadAllExcelApiUrl(params: any) {
  const params1 = Object.fromEntries(
    Object.entries(params).filter(([_, value]) => value !== undefined),
  ) as any;

  const qs = new URLSearchParams(params1);
  // TODO: 替换为实际的下载地址
  return `http://localhost:5001/api/mes/traceability/workstation/download-all?${qs.toString()}`;
}
